using MicroMsg.Network;
using System;
namespace MicroMsg.Scene.Image
{
	public class DownloadImgContextMgr : ContextMgrBase<DownloadImgContext>
	{
		private const string TAG = "DownloadImgContextMgr";
		public static DownloadImgContextMgr gDownImgContextMgr;
		public static DownloadImgContextMgr getInstance()
		{
			if (DownloadImgContextMgr.gDownImgContextMgr == null)
			{
				DownloadImgContextMgr.gDownImgContextMgr = new DownloadImgContextMgr();
			}
			return DownloadImgContextMgr.gDownImgContextMgr;
		}
		public DownloadImgContext getContextBySvrid(int svrID)
		{
			DownloadImgContext result;
			lock (this.mQueueLock)
			{
				if (this.mContextQueue.isEmpty())
				{
					result = null;
				}
				else
				{
					for (ListNode next = this.mContextQueue._head._next; next != null; next = next._next)
					{
						DownloadImgContext downloadImgContext = (DownloadImgContext)next._obj;
						if (downloadImgContext != null && downloadImgContext.mImgInfo.nMsgSvrID == svrID)
						{
							result = downloadImgContext;
							return result;
						}
					}
					result = null;
				}
			}
			return result;
		}
		public bool isMsgSvrIDInQueue(int svrID)
		{
			bool result;
			lock (this.mQueueLock)
			{
				if (this.mContextQueue.isEmpty())
				{
					result = false;
				}
				else
				{
					for (ListNode next = this.mContextQueue._head._next; next != null; next = next._next)
					{
						DownloadImgContext downloadImgContext = (DownloadImgContext)next._obj;
						if (downloadImgContext != null && downloadImgContext.mImgInfo.nMsgSvrID == svrID)
						{
							result = true;
							return result;
						}
					}
					result = false;
				}
			}
			return result;
		}
	}
}
